package com.example.mapper;

import com.example.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Description:
 * @author: GaoPeng
 * @date: 2021/5/26 21:31
 */
public interface UserMapper extends Mapper<User> {

    @Select("select count(id) from User where username=#{username}")
    Integer selectCountUser(String username);

    /*@Insert("insert into User values(#{id},#{username},#{password},#{status})")
    Integer insertUser(User user);*/

    @Select("select password from User where username=#{username}")
    String selectPasswordByUsername(String username);

    @Update("update  User set password=#{password} where username=#{username}")
    Boolean modifyPassword(@Param("username")String username,@Param("password")String password);

    @Select("select id from User where username=#{username}")
    Integer selectIdByUsername(String username);

    @Update("UPDATE User SET username = #{username},password = #{password},status = #{status},realname = #{realname},city = #{city},address = #{address},post_code = #{post_code}" +
            ",idcard_no = #{idcard_no},idcard_kind = #{idcard_kind},email = #{email} WHERE id =#{id}")
    Integer modifyUser(User user);

    @Select("select * from User where id=#{id}")
    User selectById(Integer id);

    @Insert("insert into notice values(null,#{content})")
    Integer insertNotice(String content);

    @Select("select content from notice")
    List<String> selectAllNotice();
}
